package com.laikan.reader.article.adapter.holder;

import android.net.Uri;
import android.support.v7.widget.RecyclerView;
import android.text.TextUtils;
import android.view.View;
import android.widget.TextView;
import com.facebook.drawee.view.SimpleDraweeView;
import com.laikan.library.utils.DeviceUtil;
import com.laikan.reader.R;
import com.laikan.reader.core.LaikanApplication;
import com.laikan.reader.core.bean.BookFocusBean;

/**
 * Created by Administrator on 2016/10/21.
 */
public class ContentHolder extends RecyclerView.ViewHolder{
    private BookFocusBean.BookFocusDataList bean;
    private View mRootView;
    private TextView tv_bookfocus_title, tv_bookfocus_author, tv_bookfocus_readtotal, tv_focusdetail_likelook;
    private SimpleDraweeView iv_bookfocus_item_icon;

    public ContentHolder(View view){
        super(view);
        mRootView = view;
        initView(view);
    }
    public View initView(View view) {
        tv_bookfocus_title = (TextView)view.findViewById(R.id.tv_title);
        tv_bookfocus_author = (TextView)view.findViewById(R.id.tv_author_name);
        tv_bookfocus_readtotal = (TextView)view.findViewById(R.id.tv_read_total);
        iv_bookfocus_item_icon = (SimpleDraweeView)view.findViewById(R.id.iv_bookfocus_item_icon);
        tv_focusdetail_likelook = (TextView)view.findViewById(R.id.tv_focusdetail_likelook);
        return view;
    }

    public void setData(BookFocusBean.BookFocusDataList bean) {
        this.bean = bean;
        refreshView(bean);
    }

    public void refreshView(BookFocusBean.BookFocusDataList bean) {
        tv_bookfocus_title.setText(bean.getTitle());
        tv_bookfocus_author.setText(bean.getAuthor());
        tv_bookfocus_readtotal.setText(DeviceUtil.getHtmlFormatedString(LaikanApplication.getInstance(), R.string.bookfocus_article_record, bean.getReadNum()));
        if (!TextUtils.isEmpty(bean.getImg())) {
            iv_bookfocus_item_icon.setImageURI(Uri.parse(bean.getImg()));
        }
        tv_focusdetail_likelook.setText(R.string.likelook_done_text);
    }
    public View getRootView() {
        return mRootView;
    }
}
